package net.oschina.app.adapter.center_message;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import net.oschina.app.R;
import net.oschina.app.base.BaseAdapter;
import net.oschina.app.bean.PraiseBean;
import net.oschina.app.util.CommonUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by elf on 2017/1/16.
 * 我---消息界面的赞了我界面
 */

public class GoodsAdapter extends BaseAdapter {
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(CommonUtils.getContext()).inflate(R.layout.item_goods, parent, false);
        GoodsHolder goodsHolder = new GoodsHolder(itemView);
        return goodsHolder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        GoodsHolder goodsHolder = (GoodsHolder) holder;
        PraiseBean.MytweetBean mytweetBean = (PraiseBean.MytweetBean) mDatas.get(position);
        Glide.with(CommonUtils.getContext()).load(mytweetBean.getUser().getPortrait()).into(goodsHolder.mIvUserMessage);
        goodsHolder.mTvUserNameGoods.setText(mytweetBean.getUser().getName());
        goodsHolder.mTvDateTime.setText(mytweetBean.getDatatime());
        goodsHolder.mTvTweetBody.setText(mytweetBean.getTweet().getAuthor()+" : "
                +mytweetBean.getTweet().getBody());
    }

    static class GoodsHolder extends RecyclerView.ViewHolder{
        @BindView(R.id.iv_user_message)
        CircleImageView mIvUserMessage;
        @BindView(R.id.tv_user_name_goods)
        TextView mTvUserNameGoods;
        @BindView(R.id.tv_date_time)
        TextView mTvDateTime;
        @BindView(R.id.tv_tweet_body)
        TextView mTvTweetBody;

        GoodsHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
